home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / TURB_VIS / OGRID100 / GLWINDOW.PAS < prev    next >
Pascal/Delphi Source File  |  1994-12-28  |  5KB  |  164 lines

  1. {********************************************************************
  2.  
  3.   OOGrid Library(TM) v1.0 for Borland/Turbo Pascal (Real Mode/TV)
  4.   Copyright (C) 1994 by Arturo J. Monge
  5.   Portions Copyright (C) 1989,1990 Borland International, Inc.
  6.  
  7.   OOGrid Library(TM) Window Unit:
  8.     Implementation of a TWindow's descendant that can own
  9.     a TSpreadSheet.
  10.  
  11.   Copyright (C) 1994 by Arturo J. Monge
  12.  
  13.   Last Modification : December 29th, 1994
  14.  
  15. *********************************************************************}
  16.  
  17. {$O+,F+}
  18.  
  19. unit GLWindow;
  20.  
  21. {****************************************************************************}
  22.                                  interface
  23. {****************************************************************************}
  24.  
  25. uses Objects, Views, GLViews;
  26.  
  27. const
  28.  
  29. { Color Palettes }
  30.  
  31. { Application palettes - must be added to the standard application palette - }
  32.  
  33. CSpreadSheetColor      = #$1F#$1F#$1F#$1F#$1E#$3F#$3F#$17#$1F#$7F#$7F#$7F#$2F+
  34.                          #$3F#$70#$7F#$2F#$4F#$74#$7F#$2F#$BF#$F0#$FF#$AF;
  35. CSpreadSheetBlackWhite = #$0F#$0F#$0F#$0F#$07#$0F#$0F#$07#$0F#$7F#$7F#$7F#$0F+
  36.                          #$0F#$70#$7F#$0F#$7F#$7F#$7F#$0F#$8F#$F0#$FF#$8F;
  37. CSpreadSheetMonochrome = #$0F#$0F#$0F#$0F#$07#$0F#$0F#$07#$0F#$70#$70#$70#$0F+
  38.                          #$0F#$07#$70#$0F#$70#$0F#$80#$0F#$8F#$8F#$F0#$8F;
  39.  
  40. { TSpreadSheetWindow palette for use without the help file }
  41. { This is the one used in the TSpreadSheetWindow object }
  42.  
  43. CSpreadSheetWindow1 = #50#51#52#64#65#66#67#68#69#70#71#72#73#74#75#76+
  44.                       #77#78#79#80#81#82#83#84#85#86#87#88;
  45.  
  46. { TSpreadSheetWindow palette for use with the help file }
  47.  
  48. CSpreadSheetWindow2 = #50#51#52#72#73#74#75#76#77#78#79#80#81#82#83#84+
  49.                       #85#86#87#88#89#90#91#92#93#94#95#96;
  50.  
  51. { TSpreadSheetWindow palette layout }
  52.  
  53.   { 1..8 = Blue Window palette }
  54.   { 9 = Inputline Normal }
  55.   { 10 = Inputline Selected }
  56.   { 11 = Inputline Arrows }
  57.   { 12 = Empty Cell }
  58.   { 13 = Value Cell }
  59.   { 14 = Text Cell }
  60.   { 15 = Repeat Cell }
  61.   { 16 = Formula Cell }
  62.   { 17 = Column headers }
  63.   { 18 = Row numbers }
  64.   { 19 = Cell Data Area }
  65.   { 20 = Cell Contents Area }
  66.   { 21 = Spreadsheet Info Area }
  67.   { 22 = Cell in Block }
  68.   { 23 = Cell Highlighted }
  69.   { 24 = Cell Highlighted in Block }
  70.   { 25 = Unlocked Cell }
  71.   { 26 = Unlocked Cell in Block }
  72.   { 27 = Unlocked Cell Highlighted }
  73.   { 28 = Unlocked Cell Highlighted in Block }
  74.   { 29 = Cell Error }
  75.   { 30 = Cell Error in Block }
  76.   { 31 = Cell Error Highlighted }
  77.   { 32 = Cell Error Highlighted in Block }
  78.   { 33 = Unlocked Cell Error }
  79.   { 34 = Unlocked Cell Error in Block }
  80.   { 35 = Unlocked Cell Error Highlighted }
  81.   { 36 = Unlocked Cell Error Highlighted in Block }
  82.  
  83.  
  84.  
  85. type
  86.  
  87.   PSpreadSheetWindow = ^TSpreadSheetWindow;
  88.   TSpreadSheetWindow = object(TWindow)
  89.   { A TWindow's descendant that can own a TSpreadSheet object }
  90.     constructor Init(Bounds: TRect; ATitle: String; ANumber: Integer);
  91.     function GetPalette: PPalette; virtual;
  92.     procedure SizeLimits(var Min, Max: TPoint); virtual;
  93.     function StandardScrollBar(AOptions : Word): PLimScrollBar;
  94.   end; {...TSpreadSheetWindow }
  95.  
  96. {****************************************************************************}
  97.                                implementation
  98. {****************************************************************************}
  99.  
  100. uses App, Drivers, GLSupprt;
  101.  
  102. {** TSpreadSheet Window **}
  103.  
  104. constructor TSpreadSheetWindow.Init(Bounds: TRect; ATitle: String;
  105.             ANumber: Integer);
  106. begin
  107.   TWindow.Init(Bounds, ATitle, ANumber);
  108.   Options := Options or ofTileable;
  109. end; {...TSpreadSheetWindow.Init }
  110.  
  111.  
  112. function TSpreadSheetWindow.GetPalette: PPalette;
  113. { Extends the palette for a blue window to include the entries used by
  114.   the TSpreadSheet object }
  115. const
  116.   CNewPalette = CBlueWindow + CSpreadSheetWindow1;
  117.   PNewPalette : string[Length(CNewPalette)] = CNewPalette;
  118. begin
  119.   GetPalette := @PNewPalette;
  120. end; {...TSpreadSheetWindow.GetPalette }
  121.  
  122.  
  123. procedure TSpreadSheetWindow.SizeLimits(var Min, Max: TPoint);
  124. { Returns the size limits of the window taking into account the size limits
  125.   of a spreadsheet }
  126. begin
  127.   Min.X := 18;
  128.   Min.Y := 7;
  129.   Max := Owner^.Size;
  130. end; {...TSpreadSheetWindow.SizeLimits }
  131.  
  132.  
  133. function TSpreadSheetWindow.StandardScrollBar(AOptions : Word): PLimScrollBar;
  134. { Returns a pointer to a limited scrolling scrollbar }
  135. var
  136.   Bounds, R : TRect;
  137.   ScrollBar : PLimScrollBar;
  138. begin
  139.   GetExtent(Bounds);
  140.   if (AOptions and sbVertical) <> 0 then
  141.     begin
  142.       Move(Bounds, R, Sizeof(Bounds));
  143.       R.A.X := R.B.X - 1;
  144.       Inc(R.A.Y);
  145.       Dec(R.B.Y);
  146.       ScrollBar := New(PLimScrollBar, Init(R, DefaultVScrollBarLimit));
  147.       ScrollBar^.EventMask := evMouseDown;
  148.       StandardScrollBar := ScrollBar;
  149.       Insert(ScrollBar);
  150.     end {...if (AOptions and sbVertical) <> 0 }
  151.   else if (AOptions and sbHorizontal) = 0 then
  152.     begin
  153.       Move(Bounds, R, Sizeof(Bounds));
  154.       R.A.Y := R.B.Y - 1;
  155.       Inc(R.A.X, 2);
  156.       Dec(R.B.X, 2);
  157.       ScrollBar := New(PLimScrollBar, Init(R, DefaultHScrollBarLimit));
  158.       ScrollBar^.EventMask := evMouseDown;
  159.       StandardScrollBar := ScrollBar;
  160.       Insert(ScrollBar);
  161.     end; {...else if (AOptions and sbHorizontal) = 0 }
  162. end; {...TSpreadSheetWindow.StandardScrollBars }
  163.  
  164. end.